package com.ruoyi.mall.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.mall.domain.MallCustomer;
import com.ruoyi.mall.mapper.MallCustomerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mall.mapper.MallEmployeeMapper;
import com.ruoyi.mall.domain.MallEmployee;
import com.ruoyi.mall.service.IMallEmployeeService;

/**
 * 员工管理Service业务层处理
 * 
 * @author banana_slices
 * @date 2024-12-01
 */
@Service
public class MallEmployeeServiceImpl extends ServiceImpl<MallEmployeeMapper, MallEmployee> implements IMallEmployeeService
{
    @Autowired
    private MallEmployeeMapper mallEmployeeMapper;

    /**
     * 查询员工管理
     * 
     * @param employeeId 员工管理主键
     * @return 员工管理
     */
    @Override
    public MallEmployee selectMallEmployeeByEmployeeId(Long employeeId)
    {
        return mallEmployeeMapper.selectMallEmployeeByEmployeeId(employeeId);
    }

    /**
     * 查询员工管理列表
     * 
     * @param mallEmployee 员工管理
     * @return 员工管理
     */
    @Override
    public List<MallEmployee> selectMallEmployeeList(MallEmployee mallEmployee)
    {
        return mallEmployeeMapper.selectMallEmployeeList(mallEmployee);
    }

    /**
     * 新增员工管理
     * 
     * @param mallEmployee 员工管理
     * @return 结果
     */
    @Override
    public int insertMallEmployee(MallEmployee mallEmployee)
    {
        mallEmployee.setCreateTime(DateUtils.getNowDate());
        return mallEmployeeMapper.insertMallEmployee(mallEmployee);
    }

    /**
     * 修改员工管理
     * 
     * @param mallEmployee 员工管理
     * @return 结果
     */
    @Override
    public int updateMallEmployee(MallEmployee mallEmployee)
    {
        mallEmployee.setUpdateTime(DateUtils.getNowDate());
        return mallEmployeeMapper.updateMallEmployee(mallEmployee);
    }

    /**
     * 批量删除员工管理
     * 
     * @param employeeIds 需要删除的员工管理主键
     * @return 结果
     */
    @Override
    public int deleteMallEmployeeByEmployeeIds(Long[] employeeIds)
    {
        return mallEmployeeMapper.deleteMallEmployeeByEmployeeIds(employeeIds);
    }

    /**
     * 删除员工管理信息
     * 
     * @param employeeId 员工管理主键
     * @return 结果
     */
    @Override
    public int deleteMallEmployeeByEmployeeId(Long employeeId)
    {
        return mallEmployeeMapper.deleteMallEmployeeByEmployeeId(employeeId);
    }

    @Override
    public Boolean checkEmployeeExist(Long employeeId) {
        if (employeeId == null) return false;
        //设置查询条件
        LambdaQueryWrapper<MallEmployee> lqw = new LambdaQueryWrapper<>();
        lqw.eq(MallEmployee::getEmployeeId, employeeId);
        lqw.eq(MallEmployee::getDelFlag, "0");
        //调用查询业务
        return mallEmployeeMapper.selectOne(lqw) != null;
    }
}
